-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update contracts and packages to cw 0.13.2 #220
Conversation
contracts/cw4-stake/src/contract.rs
Outdated
@@ -158,6 +158,7 @@ pub fn handle_unbond( | |||
}) | |||
} | |||
|
|||
#[allow(const_item_mutation)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this linter config the following error is thrown:
warning: taking a mutable reference to a `const` item
--> contracts/cw4-stake/src/contract.rs:184:5
|
184 | / TOTAL.update(storage, |total| -> StdResult<_> {
185 | | let res = total + new.unwrap_or_default() - old.unwrap_or_default();
186 | | Ok(res)
187 | | })?;
| |______^
|
= note: `#[warn(const_item_mutation)]` on by default
= note: each usage of a `const` item creates a new temporary
= note: the mutable reference will refer to this temporary, not the original `const` item
note: mutable reference created due to call to this method
--> /code/packages/storage-plus/src/item.rs:64:5
|
64 | / pub fn update<A, E>(&mut self, store: &mut dyn Storage, action: A) -> Result<T, E>
65 | | where
66 | | A: FnOnce(T) -> Result<T, E>,
67 | | E: From<StdError>,
... |
72 | | Ok(output)
73 | | }
| |_____^
note: `const` item defined here
--> contracts/cw4-stake/src/state.rs:25:1
|
25 | pub const TOTAL: Item<u64> = Item::new(TOTAL_KEY);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted
Compiler assumes the TOTAL
value is being mutated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you're using the same linter version than the CI:
export CLIP_VERSION="+1.47.0"
cargo $CLIP_VERSION clippy -- -D warnings
When doing that, this warning is not reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clippy version mismatch is why you're hitting errors in the CI, by the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah you are right, I was running on rust version 1.49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is the &mut self
in update.
I think this was fixed (or at least reported).
I will check, we should definitely modify that - not disable the warning, but make it non mut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
contracts/cw4-stake/src/contract.rs
Outdated
@@ -158,6 +158,7 @@ pub fn handle_unbond( | |||
}) | |||
} | |||
|
|||
#[allow(const_item_mutation)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you're using the same linter version than the CI:
export CLIP_VERSION="+1.47.0"
cargo $CLIP_VERSION clippy -- -D warnings
When doing that, this warning is not reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed some hanging &mut self
which were rightly causing linter errors.
Otherwise, looks good.
No description provided.